Re: [SQL] Agregate Problem? - Mailing list pgsql-sql

From Herouth Maoz
Subject Re: [SQL] Agregate Problem?
Date
Msg-id l03130309b3dc7e410a29@[147.233.159.109]
Whole thread Raw
In response to Agregate Problem?  ("Len Morgan" <len-morgan@crcom.net>)
Responses Re: [SQL] Agregate Problem?
List pgsql-sql
At 17:01 +0300 on 15/08/1999, Len Morgan wrote:


>
> SELECT itemno,sum(qty) FROM sales WHERE sale_date = 'now()::date'
>
> I would expect to get back zero rows if there were no sales today but I get
> back 1.  Of course I also get back 1 row if I only sold 1 item.  Is this a
> bug or a "feature?"

This is a correct behaviour when there is no GROUP BY. PostgreSQL does this
in GROUP BY, too, unfortunately. But it's not a big problem - you merely
have to check whether the returned row has a NULL value instead of the sum.

Herouth

--
Herouth Maoz, Internet developer.
Open University of Israel - Telem project
http://telem.openu.ac.il/~herutma




pgsql-sql by date:

Previous
From: "Len Morgan"
Date:
Subject: Agregate Problem?
Next
From: "Ross J. Reedstrom"
Date:
Subject: Re: [SQL] Multiple values for a field